﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MinhTuan;

public partial class admin_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
            String[] admin = Session["Admin"].ToString().Split(',');
            int id = int.Parse(admin[0].ToString());
            if (id > 0) Response.Redirect("http://localhost:2011/didong/admin/admin.aspx");     

    }
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        AdminUser admin = AdminUser.CheckLogin(txtname.Text, txtpass.Text);
        if (admin.Id > 0)
        {
            Session["Admin"] = admin.Id.ToString() + "," + admin.Name + "," + admin.IsFunction.ToString();
            Response.Redirect("http://localhost:2011/didong/admin/admin.aspx");
        }
        else {
            lbmessage.Text = "Mật khẩu hoặc tên đăng nhập không đúng";
            lbmessage.Visible = true;
        }

    }
}
